package tests;

import common.Utils;
import org.openqa.selenium.By;

import java.io.IOException;

public class UserPage extends Utils {
    public static String url = "http://8.155.1.153:8081/system/user";
    public UserPage() {
        super(url);
    }

    public void checkPageRight() throws IOException {
        driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div[2]/main/div/div[2]/div/div/div/div[1]/div/div[1]/div/div[1]"));
        driver.findElement(By.xpath("//*[@id=\"name\"]"));
        driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[1]/button"));
        driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[2]/button"));
        driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div[1]/button"));
        driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div[2]/button"));
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());

    }

    public void UserSearch() throws IOException {
        driver.findElement(By.xpath("//*[@id=\"name\"]")).sendKeys("LiLi");
        driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[2]/button")).click();
        String res=driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[3]/span")).getText();
        String actualres="LiLi";
        assert actualres.equals(res);
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());
    }

    public void ClearMes() throws IOException {
        driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[1]/button")).click();
        String res=driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[3]/span")).getText();
        String actualres="Admin";
        assert actualres.equals(res);
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());
    }

}
